package com.atcper;

import java.lang.reflect.Field;

/**
 * @author : ranzlupup
 * @date : 2023/2/21 16:05
 */
public class Main {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        String s = "this";
        System.out.println("修改前s指向地址的值：" + s);
        // 通过反射修改String的值
        Field f = s.getClass().getDeclaredField("value");
        f.setAccessible(true);
        f.set(s, "that".toCharArray());
        System.out.println("修改后s指向地址的值：" + s);

    }
}

